package com.xjj.myoa.service.Impl;

import com.xjj.myoa.dao.UserMapper;
import com.xjj.myoa.model.OaUser;
import com.xjj.myoa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service  //表示当前这个java类是属于业务层的。作用：把UserServiceImpl这个类创建对象，并且注入到spring容器当中，供程序使用
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public OaUser getUserByUserName(String userName) {
        OaUser oaUser = userMapper.findUserByUserName(userName);
        return oaUser;
    }


    @Override
    public List<OaUser> getUserListService() {
        /*调用dao层的方法逻辑处理
        * 1.
        * 2.
        * 3.
        * */
        List<OaUser> oaUserList = userMapper.findUserList();
        return oaUserList;
    }

    @Override
    public Boolean removeUserService(int id) {
        //调用dao层的方法完成逻辑处理
       boolean result = userMapper.deleteUserById(id);
        return result;
    }

    @Override
    public boolean addUserService(OaUser oaUser) {
        //调用dao层的方法完成逻辑处理
        boolean result =  userMapper.saveUser(oaUser);
        return result;
    }

    @Override
    public boolean editUserService(OaUser oaUser) {
        //调用dao层的方法完成逻辑处理
        boolean result =  userMapper.updateUser(oaUser);
        return result;
    }
}
